/* 
							     bAdmin FS 
							Copyright (C) 2008-2009
							by bogeyman_EST
							
	Legal:
		Version: MPL 1.1
		
		The contents of this file are subject to the Mozilla Public License
		Version 1.1 (the "License"); you may not use this file except in
		compliance with the License. You may obtain a copy of the License at
		http://www.mozilla.org/MPL/

		Software distributed under the License is distributed on an "AS IS"
		basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
		License for the specific language governing rights and limitations
		under the License.

		The Original Code is The bAdmin 0.8 SA-MP filterscript.

		The Initial Developer of the Original Code is bogeyman_EST.
		Portions created by the Initial Developer are Copyright (C) 2008-2009. All Rights Reserved.

		Contributor(s): Some functions made by: Y_Less, DracoBlue .

	
	

*/

//Modify the next line for translations!
#include <bAdmin\english>

#include <a_samp>
#include <dini>

//You do not have to remove this include, it will not cause any errors if you don't have the include!
#tryinclude <a_sampmysql>

#tryinclude <YSF>

#define dcmd(%1,%2,%3)      	if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define USER_FILE            	"\\bAdmin\\Users\\%s.ini"
#define VERSION              	"0.8"	
#define MIN_VEHI_ID	         	400
#define MAX_VEHI_ID	         	611
#define COLOR_GREEN          	0x33AA33AA
#define COLOR_RED            	0xFF0000FF
#define COLOR_YELLOW         	0xFFFF00AA
#define COLOR_BLUE           	0x00FFFFFF
#define COLOR_LGREEN         	0x00FF00FF
#define COLOR_GREY              0xAFAFAFAA
new FALSE = false;
#define 						SendMsg(%1,%2,%3,%4) do{new sendfstring[128];format(sendfstring,256,(%3),%4);SendClientMessage((%1), (%2) ,sendfstring);}while(FALSE)
#define 						SendAllMsg(%1,%2,%3) do{new sendfstring[128];format(sendfstring,256,(%2),%3);SendClientMessageToAll((%1),sendfstring);}while(FALSE)
#define 						SendAMsg(%1,%2,%3) do{new sendfstring[128];format(sendfstring,256,(%2),%3);AdminMsg((%1), sendfstring);}while(FALSE)
#define 						SendAWarn(%1,%2,%3) do{new sendfstring[128];format(sendfstring,256,(%2),%3);AdminWarn((%1), sendfstring);}while(FALSE)
new anns;
new mute[MAX_PLAYERS];
new level[MAX_PLAYERS];
new logged[MAX_PLAYERS];
new sscore;
new smoney;
new mysql;
new msgs;
new mysql_table[128];
new mysql_db[128];
new mysql_pass[128];
new mysql_user[128];
new mysql_host[128];
new logging;
new file[128];
new jailed[MAX_PLAYERS];
new Menu:Tunning;
new Menu:Ccolors;
new Menu:Wheels;
new nopm[MAX_PLAYERS];
new seepms[MAX_PLAYERS];
new wasincar[MAX_PLAYERS];
enum cageenum 
{
	cage1,
	cage2,
	cage3,
	cage4,
	cage5,
	cage6,
	caged
}
enum cagepe
{
	Float:cx,
	Float:cy, 
	Float:cz
}
new cages[MAX_PLAYERS][cageenum];
new cagep[MAX_PLAYERS][cagepe];
new speedhack[MAX_PLAYERS];
enum SavePlayerPosEnum
{
    Float:LastX,
    Float:LastY,
    Float:LastZ
}
new SavePlayerPos[MAX_PLAYERS][SavePlayerPosEnum];

new Text:annTD;
enum ejail
{
	Float:ex,
	Float:ey,
	Float:ez,
	interior
}
enum ejail2
{
	Float:ex,
	Float:ey,
	Float:ez,
	interior
}

new oldpos[MAX_PLAYERS][ejail2];
new jailpos[][ejail] = {/*					Jail cell positions for usage with /jail		*/
	{198.2198,162.2697,1003.0300, 3},/*				Syntax: 						*/
	{193.5255,175.0387,1003.0234, 3},/*		         {x, y, z, interior} 						*/
	{197.6301,175.3524,1003.0234, 3}
};

new lstring[5][128];/* 			Admin level names. 
							Check config.ini to change them! 			*/
stock RPN(id)
{
	new tehname[MAX_PLAYER_NAME];
	GetPlayerName(id, tehname, sizeof(tehname));
	return tehname;
}
new aVehicleNames[212][] = {	// Betamaster
	{"Landstalker"},
	{"Bravura"},
	{"Buffalo"},
	{"Linerunner"},
	{"Perrenial"},
	{"Sentinel"},
	{"Dumper"},
	{"Firetruck"},
	{"Trashmaster"},
	{"Stretch"},
	{"Manana"},
	{"Infernus"},
	{"Voodoo"},
	{"Pony"},
	{"Mule"},
	{"Cheetah"},
	{"Ambulance"},
	{"Leviathan"},
	{"Moonbeam"},
	{"Esperanto"},
	{"Taxi"},
	{"Washington"},
	{"Bobcat"},
	{"Mr Whoopee"},
	{"BF Injection"},
	{"Hunter"},
	{"Premier"},
	{"Enforcer"},
	{"Securicar"},
	{"Banshee"},
	{"Predator"},
	{"Bus"},
	{"Rhino"},
	{"Barracks"},
	{"Hotknife"},
	{"Trailer 1"}, //artict1
	{"Previon"},
	{"Coach"},
	{"Cabbie"},
	{"Stallion"},
	{"Rumpo"},
	{"RC Bandit"},
	{"Romero"},
	{"Packer"},
	{"Monster"},
	{"Admiral"},
	{"Squalo"},
	{"Seasparrow"},
	{"Pizzaboy"},
	{"Tram"},
	{"Trailer 2"}, //artict2
	{"Turismo"},
	{"Speeder"},
	{"Reefer"},
	{"Tropic"},
	{"Flatbed"},
	{"Yankee"},
	{"Caddy"},
	{"Solair"},
	{"Berkley's RC Van"},
	{"Skimmer"},
	{"PCJ-600"},
	{"Faggio"},
	{"Freeway"},
	{"RC Baron"},
	{"RC Raider"},
	{"Glendale"},
	{"Oceanic"},
	{"Sanchez"},
	{"Sparrow"},
	{"Patriot"},
	{"Quad"},
	{"Coastguard"},
	{"Dinghy"},
	{"Hermes"},
	{"Sabre"},
	{"Rustler"},
	{"ZR-350"},
	{"Walton"},
	{"Regina"},
	{"Comet"},
	{"BMX"},
	{"Burrito"},
	{"Camper"},
	{"Marquis"},
	{"Baggage"},
	{"Dozer"},
	{"Maverick"},
	{"News Chopper"},
	{"Rancher"},
	{"FBI Rancher"},
	{"Virgo"},
	{"Greenwood"},
	{"Jetmax"},
	{"Hotring"},
	{"Sandking"},
	{"Blista Compact"},
	{"Police Maverick"},
	{"Boxville"},
	{"Benson"},
	{"Mesa"},
	{"RC Goblin"},
	{"Hotring Racer A"}, //hotrina
	{"Hotring Racer B"}, //hotrinb
	{"Bloodring Banger"},
	{"Rancher"},
	{"Super GT"},
	{"Elegant"},
	{"Journey"},
	{"Bike"},
	{"Mountain Bike"},
	{"Beagle"},
	{"Cropdust"},
	{"Stunt"},
	{"Tanker"}, //petro
	{"Roadtrain"},
	{"Nebula"},
	{"Majestic"},
	{"Buccaneer"},
	{"Shamal"},
	{"Hydra"},
	{"FCR-900"},
	{"NRG-500"},
	{"HPV1000"},
	{"Cement Truck"},
	{"Tow Truck"},
	{"Fortune"},
	{"Cadrona"},
	{"FBI Truck"},
	{"Willard"},
	{"Forklift"},
	{"Tractor"},
	{"Combine"},
	{"Feltzer"},
	{"Remington"},
	{"Slamvan"},
	{"Blade"},
	{"Freight"},
	{"Streak"},
	{"Vortex"},
	{"Vincent"},
	{"Bullet"},
	{"Clover"},
	{"Sadler"},
	{"Firetruck LA"}, //firela
	{"Hustler"},
	{"Intruder"},
	{"Primo"},
	{"Cargobob"},
	{"Tampa"},
	{"Sunrise"},
	{"Merit"},
	{"Utility"},
	{"Nevada"},
	{"Yosemite"},
	{"Windsor"},
	{"Monster A"}, //monstera
	{"Monster B"}, //monsterb
	{"Uranus"},
	{"Jester"},
	{"Sultan"},
	{"Stratum"},
	{"Elegy"},
	{"Raindance"},
	{"RC Tiger"},
	{"Flash"},
	{"Tahoma"},
	{"Savanna"},
	{"Bandito"},
	{"Freight Flat"}, //freiflat
	{"Streak Carriage"}, //streakc
	{"Kart"},
	{"Mower"},
	{"Duneride"},
	{"Sweeper"},
	{"Broadway"},
	{"Tornado"},
	{"AT-400"},
	{"DFT-30"},
	{"Huntley"},
	{"Stafford"},
	{"BF-400"},
	{"Newsvan"},
	{"Tug"},
	{"Trailer 3"}, //petrotr
	{"Emperor"},
	{"Wayfarer"},
	{"Euros"},
	{"Hotdog"},
	{"Club"},
	{"Freight Carriage"}, //freibox
	{"Trailer 3"}, //artict3
	{"Andromada"},
	{"Dodo"},
	{"RC Cam"},
	{"Launch"},
	{"Police Car (LSPD)"},
	{"Police Car (SFPD)"},
	{"Police Car (LVPD)"},
	{"Police Ranger"},
	{"Picador"},
	{"S.W.A.T. Van"},
	{"Alpha"},
	{"Phoenix"},
	{"Glendale"},
	{"Sadler"},
	{"Luggage Trailer A"}, //bagboxa
	{"Luggage Trailer B"}, //bagboxb
	{"Stair Trailer"}, //tugstair
	{"Boxville"},
	{"Farm Plow"}, //farmtr1
	{"Utility Trailer"} //utiltr1
};

new WeaponNames[][32] = {
	{"Unarmed (Fist)"}, // 0
	{"Brass Knuckles"}, // 1
	{"Golf Club"}, // 2
	{"Night Stick"}, // 3
	{"Knife"}, // 4
	{"Baseball Bat"}, // 5
	{"Shovel"}, // 6
	{"Pool Cue"}, // 7
	{"Katana"}, // 8
	{"Chainsaw"}, // 9
	{"Purple Dildo"}, // 10
	{"Big White Vibrator"}, // 11
	{"Medium White Vibrator"}, // 12
	{"Small White Vibrator"}, // 13
	{"Flowers"}, // 14
	{"Cane"}, // 15
	{"Grenade"}, // 16
	{"Teargas"}, // 17
	{"Molotov"}, // 18
	{" "}, // 19
	{" "}, // 20
	{" "}, // 21
	{"Colt 45"}, // 22
	{"Colt 45 (Silenced)"}, // 23
	{"Desert Eagle"}, // 24
	{"Normal Shotgun"}, // 25
	{"Sawnoff Shotgun"}, // 26
	{"Combat Shotgun"}, // 27
	{"Micro Uzi (Mac 10)"}, // 28
	{"MP5"}, // 29
	{"AK47"}, // 30
	{"M4"}, // 31
	{"Tec9"}, // 32
	{"Country Rifle"}, // 33
	{"Sniper Rifle"}, // 34
	{"Rocket Launcher"}, // 35
	{"Heat-Seeking Rocket Launcher"}, // 36
	{"Flamethrower"}, // 37
	{"Minigun"}, // 38
	{"Satchel Charge"}, // 39
	{"Detonator"}, // 40
	{"Spray Can"}, // 41
	{"Fire Extinguisher"}, // 42
	{"Camera"}, // 43
	{"Night Vision Goggles"}, // 44
	{"Infrared Vision Goggles"}, // 45
	{"Parachute"}, // 46
	{"Fake Pistol"} // 47
};





/*----------------------------------------------------------------------------*-
Function:
	sscanf
Params:
	string[] - String to extract parameters from.
	format[] - Parameter types to get.
	{Float,_}:... - Data return variables.
Return:
	0 - Successful, not 0 - fail.
Notes:
	A fail is either insufficient variables to store the data or insufficient
	data for the format string - excess data is disgarded.
 
	A string in the middle of the input data is extracted as a single word, a
	string at the end of the data collects all remaining text.
 
	The format codes are:
 
	c - A character.
	d, i - An integer.
	h, x - A hex number (e.g. a colour).
	f - A float.
	s - A string.
	z - An optional string.
	pX - An additional delimiter where X is another character.
	'' - Encloses a litteral string to locate.
	u - User, takes a name, part of a name or an id and returns the id if they're connected.
 
	Now has IsNumeric integrated into the code.
 
	Added additional delimiters in the form of all whitespace and an
	optionally specified one in the format string.
-*----------------------------------------------------------------------------*/
 
stock sscanf(string[], format[], {Float,_}:...)
{
	#if defined isnull
		if (isnull(string))
	#else
		if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
	#endif
		{
			return format[0];
		}
	#pragma tabsize 4
	new
		formatPos = 0,
		stringPos = 0,
		paramPos = 2,
		paramCount = numargs(),
		delim = ' ';
	while (string[stringPos] && string[stringPos] <= ' ')
	{
		stringPos++;
	}
	while (paramPos < paramCount && string[stringPos])
	{
		switch (format[formatPos++])
		{
			case '\0':
			{
				return 0;
			}
			case 'i', 'd':
			{
				new
					neg = 1,
					num = 0,
					ch = string[stringPos];
				if (ch == '-')
				{
					neg = -1;
					ch = string[++stringPos];
				}
				do
				{
					stringPos++;
					if ('0' <= ch <= '9')
					{
						num = (num * 10) + (ch - '0');
					}
					else
					{
						return -1;
					}
				}
				while ((ch = string[stringPos]) > ' ' && ch != delim);
				setarg(paramPos, 0, num * neg);
			}
			case 'h', 'x':
			{
				new
					num = 0,
					ch = string[stringPos];
				do
				{
					stringPos++;
					switch (ch)
					{
						case 'x', 'X':
						{
							num = 0;
							continue;
						}
						case '0' .. '9':
						{
							num = (num << 4) | (ch - '0');
						}
						case 'a' .. 'f':
						{
							num = (num << 4) | (ch - ('a' - 10));
						}
						case 'A' .. 'F':
						{
							num = (num << 4) | (ch - ('A' - 10));
						}
						default:
						{
							return -1;
						}
					}
				}
				while ((ch = string[stringPos]) > ' ' && ch != delim);
				setarg(paramPos, 0, num);
			}
			case 'c':
			{
				setarg(paramPos, 0, string[stringPos++]);
			}
			case 'f':
			{
				setarg(paramPos, 0, _:floatstr(string[stringPos]));
			}
			case 'p':
			{
				delim = format[formatPos++];
				continue;
			}
			case '\'':
			{
				new
					end = formatPos - 1,
					ch;
				while ((ch = format[++end]) && ch != '\'') {}
				if (!ch)
				{
					return -1;
				}
				format[end] = '\0';
				if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
				{
					if (format[end + 1])
					{
						return -1;
					}
					return 0;
				}
				format[end] = '\'';
				stringPos = ch + (end - formatPos);
				formatPos = end + 1;
			}
			case 'u':
			{
				new
					end = stringPos - 1,
					id = 0,
					bool:num = true,
					ch;
				while ((ch = string[++end]) && ch != delim)
				{
					if (num)
					{
						if ('0' <= ch <= '9')
						{
							id = (id * 10) + (ch - '0');
						}
						else
						{
							num = false;
						}
					}
				}
				if (num && IsPlayerConnected(id))
				{
					setarg(paramPos, 0, id);
				}
				else
				{
					#if !defined foreach
						#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
						#define __SSCANF_FOREACH__
					#endif
					string[end] = '\0';
					num = false;
					new
						name[MAX_PLAYER_NAME];
					id = end - stringPos;
					foreach (Player, playerid)
					{
						GetPlayerName(playerid, name, sizeof (name));
						if (!strcmp(name, string[stringPos], true, id))
						{
							setarg(paramPos, 0, playerid);
							num = true;
							break;
						}
					}
					if (!num)
					{
						setarg(paramPos, 0, INVALID_PLAYER_ID);
					}
					string[end] = ch;
					#if defined __SSCANF_FOREACH__
						#undef foreach
						#undef __SSCANF_FOREACH__
					#endif
				}
				stringPos = end;
			}
			case 's', 'z':
			{
				new
					i = 0,
					ch;
				if (format[formatPos])
				{
					while ((ch = string[stringPos++]) && ch != delim)
					{
						setarg(paramPos, i++, ch);
					}
					if (!i)
					{
						return -1;
					}
				}
				else
				{
					while ((ch = string[stringPos++]))
					{
						setarg(paramPos, i++, ch);
					}
				}
				stringPos--;
				setarg(paramPos, i, '\0');
			}
			default:
			{
				continue;
			}
		}
		while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
		{
			stringPos++;
		}
		while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
		{
			stringPos++;
		}
		paramPos++;
	}
	do
	{
		if ((delim = format[formatPos++]) > ' ')
		{
			if (delim == '\'')
			{
				while ((delim = format[formatPos++]) && delim != '\'') {}
			}
			else if (delim != 'z')
			{
				return delim;
			}
		}
	}
	while (delim > ' ');
	return 0;
}





// udb_hash was taken from DracoBlue's inculde dudb.inc. It was copied here to remove dudb from includes.
stock udb_hash(buf[]) {
	new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
//Taken from dutils.inc by DracoBlue
stock isNumeric(const string[]) {
	new length=strlen(string);
	if (length==0) return false;
	for (new i = 0; i < length; i++) {
		if (
		(string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
		|| (string[i]=='-' && i!=0)                                             // A '-' but not at first.
		|| (string[i]=='+' && i!=0)                                             // A '+' but not at first.
		) return false;
	}
	if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
	return true;
}
//Taken from dutils.inc by DracoBlue
stock SetPlayerMoney(playerid,howmuch) {
  GivePlayerMoney(playerid,howmuch-GetPlayerMoney(playerid));
}
//Taken from dutils.inc by DracoBlue
stock Time() {
  new hour,minute,second;
  new year, month,day;
  gettime(hour, minute, second);
  getdate(year, month, day);
  return mktime(hour,minute,second,day,month,year);
}
//Taken from dutils.inc by DracoBlue
stock mktime(hour,minute,second,day,month,year) {
	new timestamp2;

	timestamp2 = second + (minute * 60) + (hour * 3600);

	new days_of_month[12];

	if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) {
			days_of_month = {31,29,31,30,31,30,31,31,30,31,30,31}; // Schaltjahr
		} else {
			days_of_month = {31,28,31,30,31,30,31,31,30,31,30,31}; // keins
		}
	new days_this_year = 0;
	days_this_year = day;
	if(month > 1) { // No January Calculation, because its always the 0 past months
		for(new i=0; i<month-1;i++) {
			days_this_year += days_of_month[i];
		}
	}
	timestamp2 += days_this_year * 86400;

	for(new j=1970;j<year;j++) {
		timestamp2 += 31536000;
		if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) )  timestamp2 += 86400; // Schaltjahr + 1 Tag
	}

	return timestamp2;
}

stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
	new Float:oldposx, Float:oldposy, Float:oldposz;
	new Float:tempposx, Float:tempposy, Float:tempposz;
	GetPlayerPos(playerid, oldposx, oldposy, oldposz);
	tempposx = (oldposx -x);
	tempposy = (oldposy -y);
	tempposz = (oldposz -z);
	if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
	{
		return 1;
	}
	return 0;
}
stock SaveStats(ID=INVALID_PLAYER_ID)
{
	new string[128];
	format(file, sizeof(file), USER_FILE, RPN(ID));
	if(IsPlayerConnected(ID) && dini_Exists(string))
	{
		format(file, sizeof(file), USER_FILE, RPN(ID));
		if(dini_Exists(file))
		{
			if(sscore) dini_IntSet(file, "score", GetPlayerScore(ID));
			if(smoney) dini_IntSet(file, "money", GetPlayerMoney(ID));
			dini_IntSet(string, "level", level[ID]);
			#if defined _sampmysql_included
			if(mysql)
			{
				format(string, 128, "UPDATE %s SET money='%i' WHERE player='%s'", mysql_table, GetPlayerMoney(ID), RPN(ID));
				samp_mysql_query(string);
				format(string, 128, "UPDATE %s SET score='%i' WHERE player='%s'", mysql_table, GetPlayerScore(ID), RPN(ID));
				samp_mysql_query(string);
				format(string, 128, "UPDATE %s SET level='%i' WHERE player='%s'", mysql_table, level[ID], RPN(ID));
				samp_mysql_query(string);
			}
			#endif
		}
	}
	else
	{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			format(file, sizeof(file), USER_FILE , RPN(i));
			if(dini_Exists(file))
			{
				dini_IntSet(file, "score", GetPlayerScore(i));
				dini_IntSet(file, "level", level[i]);
				dini_IntSet(file, "money", GetPlayerMoney(i));
				#if defined _sampmysql_included
				if(mysql)
				{
					format(string, 128, "UPDATE %s SET money='%i' WHERE player='%s'", mysql_table, GetPlayerMoney(i), RPN(i));
					samp_mysql_query(string);
					format(string, 128, "UPDATE %s SET score='%i' WHERE player='%s'", mysql_table, GetPlayerScore(i), RPN(i));
					samp_mysql_query(string);
					format(string, 128, "UPDATE %s SET level='%i' WHERE player='%s'", mysql_table, level[i], RPN(i));
					samp_mysql_query(string);
				}
				#endif
			}
		}
	}
}



stock SetStats(ID=INVALID_PLAYER_ID)
{
	format(file, sizeof(file), USER_FILE, RPN(ID));
	if(IsPlayerConnected(ID) && dini_Exists(file))
	{
		if(smoney) SetPlayerMoney(ID, dini_Int(file, "money"));
		if(sscore) SetPlayerScore(ID, dini_Int(file, "score"));
		level[ID] = dini_Int(file, "level");
		#if defined _sampmysql_included
		if(mysql)
		{
			new string[128];
			format(string, 128, "UPDATE %s SET money='%i' WHERE player='%s'", mysql_table, GetPlayerMoney(ID), RPN(ID));
			samp_mysql_query(string);
			format(string, 128, "UPDATE %s SET score='%i' WHERE player='%s'", mysql_table, GetPlayerScore(ID), RPN(ID));
			samp_mysql_query(string);
			format(string, 128, "UPDATE %s SET level='%i' WHERE player='%s'", mysql_table, level[ID], RPN(ID));
			samp_mysql_query(string);
		}
		#endif
	}
	if(!dini_Exists(file)) level[ID] = 0;
	else
	{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			format(file, sizeof(file), USER_FILE, RPN(i));
			if(IsPlayerConnected(i) && dini_Exists(file))
			{
				SetPlayerMoney(i, dini_Int(file, "money"));
				SetPlayerScore(i, dini_Int(file, "score"));
				level[i] = dini_Int(file, "level");
				#if defined _sampmysql_included
				if(mysql)
				{
					new string[128];
					format(string, 128, "UPDATE %s SET money='%i' WHERE player='%s'", mysql_table, GetPlayerMoney(i), RPN(i));
					samp_mysql_query(string);
					format(string, 128, "UPDATE %s SET score='%i' WHERE player='%s'", mysql_table, GetPlayerScore(i), RPN(i));
					samp_mysql_query(string);
					format(string, 128, "UPDATE %s SET level='%i' WHERE player='%s'", mysql_table, level[i], RPN(i));
					samp_mysql_query(string);
				}
				#endif
			}
			if(!dini_Exists(file)) level[i] = 0;
		}
	}
}
stock CreateConfig()
{
	format(file, 128, "\\bAdmin\\config.ini");
	dini_Create(file);
	dini_IntSet(file, "scoresave", 1);
	dini_IntSet(file, "moneysave", 1);
	dini_IntSet(file, "adminmsgs", 1);
	dini_IntSet(file, "logging", 1);
	dini_IntSet(file, "mysql", 0);
	dini_Set(file, "mysql_db", "changeme");
	dini_Set(file, "mysql_table", "changeme");
	dini_Set(file, "mysql_host", "changeme");
	dini_Set(file, "mysql_pass", "changeme");
	dini_Set(file, "mysql_user", "changeme");
	dini_Set(file, "level0_name", "Nublet");
	dini_Set(file, "level1_name", "Leet");
	dini_Set(file, "level2_name", "The Great Win");
	dini_Set(file, "level3_name", "The Epic Leetness");
	dini_Set(file, "level4_name", "Jesus");
}
stock GetConfig()
{
	format(file, 128, "\\bAdmin\\config.ini");
	if(!dini_Isset(file, "scoresave")) 
	{
		print(ss_notset);
		dini_IntSet(file, "scoresave", 1);
	}
	if(!dini_Isset(file, "moneysave")) 
	{
		print(ms_notset);
		dini_IntSet(file, "moneysave", 1);
	}
	if(!dini_Isset(file, "logging")) 
	{
		print(l_notset);
		dini_IntSet(file, "logging", 1);
	}
	if(!dini_Isset(file, "adminmsgs"))
	{
		print(amsg_notset);
		dini_IntSet(file, "adminmsgs", 1);
	}
	if(!dini_Isset(file, "mysql"))
	{
		print(mysql_notset);
		dini_IntSet(file, "mysql", 0);
	}
	if(!dini_Isset(file, "mysql_host")) 
	{
		print(mysqlhost_notset);
		dini_Set(file, "mysql_host", "changeme");
	}
	if(!dini_Isset(file, "mysql_db")) 
	{
		print(mysqldb_notset);
		dini_Set(file, "mysql_db", "changeme");
	}
	if(!dini_Isset(file, "mysql_table")) 
	{
		print(mysqltable_notset);
		dini_Set(file, "mysql_table", "changeme");
	}
	if(!dini_Isset(file, "mysql_user")) 
	{
		print(mysqluser_notset);
		dini_Set(file, "mysql_user", "changeme");
	}
	if(!dini_Isset(file, "mysql_pass")) 
	{
		print(mysqlpass_notset);
		dini_Set(file, "mysql_pass", "changeme");
	}
	if(!dini_Isset(file, "level0_name")) 
	{
		print(lvl0_notset);
		dini_Set(file, "level0_name", "Nublet");
	}
	if(!dini_Isset(file, "level1_name")) 
	{
		print(lvl1_notset);
		dini_Set(file, "level1_name", "Leet");
	}
	if(!dini_Isset(file, "level2_name")) 
	{
		print(lvl2_notset);
		dini_Set(file, "scoresave", "The Great Win");
	}
	if(!dini_Isset(file, "level3_name")) 
	{
		print(lvl3_notset);
		dini_Set(file, "scoresave", "The Epic Leetness");
	}
	if(!dini_Isset(file, "level4_name")) 
	{
		print(lvl4_notset);
		dini_Set(file, "scoresave", "Jesus");
	}
	sscore = dini_Int(file, "scoresave");
	smoney = dini_Int(file, "moneysave");
	mysql = dini_Int(file, "mysql");
	msgs = dini_Int(file, "adminmsgs");
	logging = dini_Int(file, "logging");
	format(mysql_db, 256, "%s", dini_Get(file, "mysql_db"));
	format(mysql_table, 256, "%s", dini_Get(file, "mysql_table"));
	format(mysql_user, 256, "%s", dini_Get(file, "mysql_user"));
	format(mysql_pass, 256, "%s", dini_Get(file, "mysql_pass"));
	format(mysql_host, 256, "%s", dini_Get(file, "mysql_host"));
	format(lstring[0], 256, "%s", dini_Get(file, "level0_name"));
	format(lstring[1], 256, "%s", dini_Get(file, "level1_name"));
	format(lstring[2], 256, "%s", dini_Get(file, "level2_name"));
	format(lstring[3], 256, "%s", dini_Get(file, "level3_name"));
	format(lstring[4], 256, "%s", dini_Get(file, "level4_name"));
}

stock AdminMsg(lvl, message[])
{
	new string[128];
	format(string, 128, adminmsg, message);
	if(msgs)
	{		
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(level[i] >= lvl)
			{
				SendClientMessage(i, COLOR_GREEN, string);
			}
		}
		print(string);
	}
	else print(string);
	if(logging)
	{
		new File:log = fopen("\\bAdmin\\log.txt", io_append);
		new year, month, day, hour, minute, second;
		gettime(hour, minute, second);
		getdate(year, month, day);
		new sendmsg[256];
		format(sendmsg, 256, "%i/%i/%i %i:%i:%i 	- 	%s\r\n", day, month, year, hour, minute, second, string);
		fwrite(log, sendmsg);
		fclose(log);
	}
}


stock AdminWarn(lvl, message[])
{
	new string[128];
	format(string, 128, adminwarn, message);
	if(msgs)
	{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(level[i] >= lvl)
			{
				SendClientMessage(i, COLOR_GREEN, string);
			}
		}
		print( string);
	}
	else print(string);
	if(logging)
	{
		new File:log = fopen("\\bAdmin\\log.txt", io_append);
		new year, month, day, hour, minute, second;
		gettime(hour, minute, second);
		getdate(year, month, day);
		new sendmsg[256];
		format(sendmsg, 256, "%i/%i/%i %i:%i:%i	-	%s\r\n", day, month, year, hour, minute, second, string);
		fwrite(log, sendmsg);
		fclose(log);
	}
}

stock TimeBan(ID, time)
{
	format(file, 128, "\\bAdmin\\Timebans\\%s.ini", RPN(ID));
	dini_Create(file);
	dini_IntSet(file, "time", Time());
	dini_IntSet(file, "duration", time*60);
	TogglePlayerControllable(ID, 0);
	SendClientMessage(ID, COLOR_RED, kickmsg);
	Kick(ID);
}

stock GetWeaponModelIDFromName(wname[])
{
    for(new i = 0; i < 48; i++) {
        if (i == 19 || i == 20 || i == 21) continue;
		if (strfind(WeaponNames[i], wname, true) != -1) {
			return i;
		}
	}
	return -1;
}

stock GetVehicleModelIDFromName(vname[])
{
	for(new i = 0; i < 211; i++) {
		if (strfind(aVehicleNames[i], vname, true) != -1) {
			return i + MIN_VEHI_ID;
		}
	}
	return -1;
}
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
	new Float:a;
	GetPlayerPos(playerid, x, y, a);
	GetPlayerFacingAngle(playerid, a);
	if (GetPlayerVehicleID(playerid)) {
	    GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
	}
	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
}

stock IDFromName(name[])
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(strfind(RPN(i), name, true) != -1 || (IsPlayerConnected(i) && strval(name) == i && isNumeric(name)))
		{
			return i;
		}
	}
	return -1;
}
stock GetPlayerSpeed(playerid)
{
	new Float:x,Float:y,Float:z;
	new Float:distancep;
	new value;
	GetPlayerPos(playerid, x, y, z);
	if(!SavePlayerPos[playerid][LastX] || !wasincar[playerid]) SavePlayerPos[playerid][LastX] = x;
	if(!SavePlayerPos[playerid][LastY] || !wasincar[playerid]) SavePlayerPos[playerid][LastY] = y;
	if(!SavePlayerPos[playerid][LastZ] || !wasincar[playerid]) SavePlayerPos[playerid][LastZ] = z;
	distancep = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[playerid][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[playerid][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[playerid][LastZ])),2));
	value = floatround(distancep * 11000);
	SavePlayerPos[playerid][LastX] = x;
	SavePlayerPos[playerid][LastY] = y;
	SavePlayerPos[playerid][LastZ] = z;
	return floatround(value/1400);
}
stock IsPlayerSpawned(playerid){
	new statex = GetPlayerState(playerid);
	if(statex != PLAYER_STATE_NONE && statex != PLAYER_STATE_WASTED && statex != PLAYER_STATE_SPAWNED) return true;
	return false;

}

public OnFilterScriptInit()
{
	#if defined _YSF_included
	new sstring[128];
	format(sstring, 128, "bAdmin %s", VERSION);
	AddServerRule("adminsys", sstring);
	#endif
	print("--------------bAdmin--------------");
	print("            bogeyAdmin            ");
	printf("    Version: %s                  ", VERSION);
	print("----------------------------------");
	print(" Scripted by:                     ");
	print("       bogeyman_EST               ");
	print("----------------------------------\n");
	print("Checking files:                   ");
	if(!dini_Exists("\\bAdmin\\config.ini"))
	{
		print(cfg_notfound);
		CreateConfig();
		print(cfg_created);
	}
	GetConfig();
	printf("----config.ini----\n");
	printf(cfg_settings);
	printf(cfg_score, sscore ? (cfg_on) : (cfg_off));
	printf(cfg_money, smoney ? (cfg_on) : (cfg_off));
	printf(cfg_admin, msgs ? (cfg_on) : (cfg_off));
	printf(cfg_log, logging ? (cfg_on) : (cfg_off));
	if(!dini_Exists("\\bAdmin\\log.txt"))
	{
		print(cfg_nolog);
		dini_Create("\\bAdmin\\log.txt");
		print(cfg_logcreated);
	}
	printf(cfg_levels);
	printf(cfg_lvl0, lstring[0]);
	printf(cfg_lvl1, lstring[1]);
	printf(cfg_lvl2, lstring[2]);
	printf(cfg_lvl3, lstring[3]);
	printf(cfg_lvl4, lstring[4]);
	printf(cfg_mysql);
	printf(cfg_mysqlsetting, mysql ? (cfg_on) : (cfg_off));
	#if defined _sampmysql_included
	if(mysql)
	{
		print(cfg_mysqlinfo);
		if(!strcmp(mysql_host, "changeme", false)) {print(cfg_hosterr); mysql = 0; goto exitmysql;}
		else printf(cfg_host, mysql_host);
		if(!strcmp(mysql_db, "changeme", false)) {print(cfg_dberr); mysql = 0; goto exitmysql;}
		else printf(cfg_db, mysql_db);
		if(!strcmp(mysql_table, "changeme", false)) {print(cfg_tablerr); mysql = 0; goto exitmysql;}
		else printf(cfg_table, mysql_table);
		if(!strcmp(mysql_user, "changeme", false)) {print(cfg_usererr); mysql = 0; goto exitmysql;}
		else printf(cfg_user, mysql_user);
		if(!strcmp(mysql_pass, "changeme", false)) {print(cfg_passerr); mysql = 0; goto exitmysql;}
		else printf(cfg_pass, mysql_pass);
		print(cfg_logging);
		samp_mysql_connect(mysql_host, mysql_user, mysql_pass);
		print(cfg_selecting);
		if(samp_mysql_select_db(mysql_db))
			print(cfg_selectdone);
		else
			print(cfg_selectfail);
		exitmysql:
	}
	#endif
	print(cfg_mysqldone);
	printf(cfg_end);
	print(loggingin);
	new string[128];
	new c = 0;
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		format(file, sizeof(string), USER_FILE, RPN(i));
		new IP[16];
		GetPlayerIp(i, IP, 16);
		if(dini_Exists(file) && IsPlayerConnected(i))
		{
			if(!strcmp(dini_Get(file, "IP"), IP, true))
			{
				SendClientMessage(i, COLOR_YELLOW, msg_autologged);
				logged[i] = 1;
				format(string, 128, alogged, RPN(i), i);
				AdminMsg(1, string);
				level[i] = dini_Int(file, "level");
				SetPlayerScore(i, dini_Int(file, "score"));
				SetPlayerMoney(i, dini_Int(file, "money"));
				format(string, 128, lvlmsg , level[i], lstring[level[i]]);
				SendClientMessage(i, COLOR_BLUE, string);
				printf(alogged, RPN(i), i);
				c++;
			}
			else SendClientMessage(i, COLOR_RED, msg_registered);
		}
		else SendClientMessage(i, COLOR_RED, msg_register);
	}
	printf(loggedin, c);
	annTD = TextDrawCreate(311.000000,131.000000,"text");
	TextDrawAlignment(annTD,2);
	TextDrawBackgroundColor(annTD,0x000000ff);
	TextDrawFont(annTD,3);
	TextDrawLetterSize(annTD,1.200000,3.000000);
	TextDrawColor(annTD,0xffffffff);
	TextDrawSetOutline(annTD,1);
	TextDrawSetProportional(annTD,1);
	TextDrawSetShadow(annTD,1);
	Tunning = CreateMenu(menu_tuning,1,20,120,150,40);
	SetMenuColumnHeader(Tunning,0,menu_parts);
	AddMenuItem(Tunning,0,menu_colors);
	AddMenuItem(Tunning,0,menu_wheels);
	AddMenuItem(Tunning,0,menu_nos);
	AddMenuItem(Tunning,0,menu_hydraulics);
	AddMenuItem(Tunning,0,menu_sound);
	Ccolors = CreateMenu(menu_tuning,1,20,120,150,40);
	SetMenuColumnHeader(Ccolors,0,menu_colors);
	AddMenuItem(Ccolors,0,menu_black);
	AddMenuItem(Ccolors,0,menu_white);
	AddMenuItem(Ccolors,0,menu_red);
	AddMenuItem(Ccolors,0,menu_green);
	AddMenuItem(Ccolors,0,menu_blue);
	AddMenuItem(Ccolors,0,menu_pink);
	AddMenuItem(Ccolors,0,menu_yellow);
	AddMenuItem(Ccolors,0,menu_pj1);
	AddMenuItem(Ccolors,0,menu_pj2);
	AddMenuItem(Ccolors,0,menu_pj3);
	Wheels = CreateMenu(menu_tuning,1,20,120,150,40);
	SetMenuColumnHeader(Wheels,0,menu_wheels);
	AddMenuItem(Wheels,0,menu_cutter);
	AddMenuItem(Wheels,0,menu_rimshine);
	AddMenuItem(Wheels,0,menu_mega);
	AddMenuItem(Wheels,0,menu_grove);
	AddMenuItem(Wheels,0,menu_switch);
	AddMenuItem(Wheels,0,menu_shadow);
	AddMenuItem(Wheels,0,menu_classic);
	AddMenuItem(Wheels,0,menu_dollar);
	AddMenuItem(Wheels,0,menu_import);
	AddMenuItem(Wheels,0,menu_atomic);

	SetTimer("stats", 600000, 1);
	SetTimer("MySqlCheckConnection", 60000, 1);
	SetTimer("anticheat", 500, 1);
	SetTimer("cagetime", 800, 1);
	return 1;
}
/*
*		ATTENTION!
*		Anticheat is currently in development and it may not work,
*		so do not complain if it doesn't work!
*/
forward anticheat();
public anticheat()
{
	new speed;
	for(new i = 0; i < GetMaxPlayers(); i++)
	{
		speed = GetPlayerSpeed(i);
		if(level[i] == 0)
		{
			if(speed > 600 && IsPlayerSpawned(i) && !speedhack[i] && GetPlayerState(i) == PLAYER_STATE_DRIVER && IsPlayerConnected(i))
			{
				SendAMsg(1, aspeedwarn, RPN(i), i);
				speedhack[i] = 1;
				SetTimerEx("speedwarn", 5000, 0, "i", i);
			}
		}
	}
}
forward speedwarn(id);
public speedwarn(id)
{
	speedhack[id] = 0;
}
forward MySQLCheckConnection();
public MySQLCheckConnection() // by Luk0r
{
	#if defined _sampmysql_included
	if(mysql)
	{
		if(samp_mysql_ping() == 0)
		{
			return 1;
		}
		else
		{
			print(mysql_dead);
			samp_mysql_close();
			samp_mysql_connect(mysql_host, mysql_user, mysql_pass);
			samp_mysql_select_db(mysql_db);
			if(samp_mysql_ping() == 0)
			{
				print(mysql_success);
				return 1;
			}
			else
			{
				print(mysql_failure);
				SendClientMessageToAll(COLOR_RED, mysql_conlost);
				SetTimerEx("SendRconCommand", 5000, 0, "s", "gmx");
				return 0;
			}
		}
	}
	#endif
	return 1;
}
forward stats();
public stats()
{
	SaveStats();
}

public OnFilterScriptExit()
{
	SaveStats();
	for(new ID = 0; ID < MAX_PLAYERS; ID++)
	{
		DestroyObject(cages[ID][cage1]);
		DestroyObject(cages[ID][cage2]);
		DestroyObject(cages[ID][cage3]);
		DestroyObject(cages[ID][cage4]);
		DestroyObject(cages[ID][cage5]);
		DestroyObject(cages[ID][cage6]);
		cages[ID][caged] = 0;
	}
	return 1;
}

public OnPlayerText(playerid, text[])
{
	if(mute[playerid])
	{
		SendClientMessage(playerid, COLOR_RED, msg_stillmuted);
		return 0;
	}
	return 1;
}
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
	if(nopm[recieverid])
	{
		SendMsg(playerid, COLOR_RED, msg_nopm, RPN(recieverid), recieverid);
		return 0;
	}
	else
	{
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(seepms[i] && playerid != i && recieverid != i)
			{
				SendMsg(i, COLOR_YELLOW, aseepms, RPN(playerid), playerid, RPN(recieverid), recieverid, text);
			}
		}
	}
	return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid, COLOR_BLUE, "---bAdmin---bogeyAdmin---By bogeyman_EST---");
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	new string[128];
	format(file, 128, "\\bAdmin\\Timebans\\%s.ini", RPN(playerid));
	if(dini_Exists(file))
	{
		if(dini_Int(file, "time")+dini_Int(file, "duration") > Time())
		{
			new secs = (dini_Int(file, "time") + dini_Int(file, "duration")) - Time();
			new mins = secs/60;
			secs = secs - mins*60;
			format(string, 128, msg_stillbanned, mins, secs);
			SendClientMessage(playerid, COLOR_RED, string);
			Kick(playerid);
			printf(astillbanned, RPN(playerid), playerid);
			format(string, 128, astillbanned, RPN(playerid), playerid);
			AdminMsg(1, string);
		}
		else
		{
			dini_Remove(file);
			SendClientMessage(playerid, COLOR_BLUE, msg_notimeban);
			printf(anotimeban, RPN(playerid), playerid);
		}
	}
	format(file, sizeof(string), USER_FILE, RPN(playerid));
	if(dini_Int(file, "banned") == 1)
	{
		SendClientMessage(playerid, COLOR_RED, msg_bannedacc);
		SendClientMessage(playerid, COLOR_RED, kickmsg);
		BanEx(playerid, rsn_bannedacc);
	}
	new IP[16];
	GetPlayerIp(playerid, IP, 16);
	if(dini_Exists(file))
	{
		if(dini_Isset(file, "greet"))
		{
			format(string, 128, "~w~%s", dini_Get(file, "greet"));
			TextDrawSetString(annTD, string);
			TextDrawShowForAll(annTD);
			SetTimer("Tdtimer", 5000, 0);
			anns++;
		}
		#if defined _sampmysql_included
		if(mysql)
		{
			format(string, 128, "UPDATE %s online='1' WHERE player='%s'", mysql_table, RPN(playerid));
			samp_mysql_query(string);
		}
		#endif
		if(!strcmp(dini_Get(file, "IP"), IP, true))
		{
			SendClientMessage(playerid, COLOR_YELLOW, msg_autologged);
			logged[playerid] = 1;
			format(string, sizeof(string), USER_FILE, RPN(playerid));
			level[playerid] = dini_Int(file, "level");
			SetPlayerScore(playerid, dini_Int(file, "score"));
			SetPlayerMoney(playerid, dini_Int(file, "money"));
			format(string, 128, alogged, RPN(playerid), playerid, level[playerid]);
			AdminMsg(1, string);
			format(string, 128, lvlmsg, level[playerid], lstring[level[playerid]]);
			SendClientMessage(playerid, COLOR_BLUE, string);
		}
		else SendClientMessage(playerid, COLOR_RED, msg_registered);
	}
	else SendClientMessage(playerid, COLOR_RED, msg_register);
	cages[playerid][caged] = 0;
	return 1;
}

public OnPlayerSpawn(playerid)
{
	if(logged[playerid])SetStats(playerid);
	return 1;
}
forward cagetime();

public cagetime()
{
	for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
	{
		if(!PlayerToPoint(3.5, playerid, cagep[playerid][cx], cagep[playerid][cy], cagep[playerid][cz]) && IsPlayerSpawned(playerid) && cages[playerid][caged] == 1)
		{
			SendClientMessage(playerid, COLOR_RED, msg_backtocage);
			SetPlayerPos(playerid, cagep[playerid][cx], cagep[playerid][cy], cagep[playerid][cz]);
		}
	}
}

public OnPlayerDisconnect(playerid, reason) 
{
	if(logged[playerid] == 1)
	{
		SaveStats(playerid);
		logged[playerid] = 0;
		level[playerid] = 0;
		seepms[playerid] = 0;
		nopm[playerid] = 0;
	}
	#if defined _sampmysql_included
	if(mysql)
	{
		new string[128];
		format(string, 128, "UPDATE %s online='0' WHERE player='%s'", mysql_table, RPN(playerid));
		samp_mysql_query(string);
	}
	#endif
	if(cages[playerid][caged] == 1)
	{
		DestroyObject(cages[playerid][cage1]);
		DestroyObject(cages[playerid][cage2]);
		DestroyObject(cages[playerid][cage3]);
		DestroyObject(cages[playerid][cage4]);
		DestroyObject(cages[playerid][cage5]);
		DestroyObject(cages[playerid][cage6]);
		cages[playerid][caged] = 0;
	}
	return 1;
}



public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(register, 8, cmdtext);//	1
	dcmd(login, 5, cmdtext);//		2
	if(IsPlayerAdmin(playerid) && level[playerid] != 4 && logged[playerid]) 
	{
		level[playerid] = 4;
		SendAMsg(1, alvl4, RPN(playerid), playerid);
	}
	dcmd(mute, 4, cmdtext);//		3
	if(mute[playerid]) 
	{
		SendClientMessage(playerid, COLOR_RED, msg_muted1);
		return SendClientMessage(playerid, COLOR_RED, msg_muted2);
	}
	dcmd(setadmin, 8, cmdtext);//	4
	dcmd(givemoney, 9, cmdtext);//	5
	dcmd(info, 4, cmdtext);//		6
	dcmd(kick, 4, cmdtext);//		7
	dcmd(ban, 3, cmdtext);//			8
	dcmd(timeban, 7, cmdtext);//		9
	dcmd(slap, 4, cmdtext);//		10
	dcmd(explode, 7, cmdtext);//		11
	dcmd(akill, 5, cmdtext);//		12
	dcmd(weap, 4, cmdtext);//		13
	dcmd(announce, 8, cmdtext);//	14
	dcmd(ann, 3, cmdtext);//			15
	dcmd(gethere, 7, cmdtext);//		16
	dcmd(goto, 4, cmdtext);//		17
	dcmd(tele, 4, cmdtext);//		18
	dcmd(health, 6, cmdtext);//		19
	dcmd(veh, 3, cmdtext);//			20
	dcmd(vhlth, 5, cmdtext);//		21
	dcmd(report, 6, cmdtext);//		22
	dcmd(jail, 4, cmdtext);//		23
	dcmd(restart, 7, cmdtext);//		24
	dcmd(loadfs, 6, cmdtext);//		25
	dcmd(unloadfs, 8, cmdtext);//	26
	dcmd(reloadfs, 8, cmdtext);//	27
	dcmd(gravity, 7, cmdtext);//		28
	dcmd(gmx, 3, cmdtext);//			29
	dcmd(reloadusers, 11, cmdtext);//30
	dcmd(tune, 4, cmdtext);//		31
	dcmd(fake, 4, cmdtext);//		32
	dcmd(crash, 5, cmdtext);//		33
	dcmd(time, 4, cmdtext);//		34
	dcmd(freeze, 6, cmdtext);//		35
	dcmd(unfreeze, 8, cmdtext);//	36
	dcmd(setgreet, 8, cmdtext);//	37
	dcmd(clearchat, 9, cmdtext);//	38
	dcmd(a, 1, cmdtext);//			39
	dcmd(nopm, 4, cmdtext);//		40
	dcmd(seepms, 6, cmdtext);//		41
	dcmd(cage, 4, cmdtext);//		42
	dcmd(weather, 7, cmdtext);//		43
	dcmd(setmoney, 8, cmdtext);//	44
	dcmd(setscore, 8, cmdtext);//	45
	dcmd(givescore, 9, cmdtext);//	46
	/*----------------------46 commands----------------------*/
	
	if(!strcmp(cmdtext, "/ahelp", true))
	{
		SendClientMessage(playerid, COLOR_BLUE, msg_commands);
		SendMsg(playerid, COLOR_YELLOW, "%s :: /report :: /nopm :: /register :: /login ::", msg_lvl0cmds);
		if(level[playerid] >= 1)
		{
			SendMsg(playerid, COLOR_YELLOW, "%s :: /a :: /info :: /kick :: /slap :: /akill :: /announce(/ann) :: /health :: /vhlth :: /tune :: /mute ::", msg_lvl1cmds);
			SendClientMessage(playerid, COLOR_YELLOW, ":: /health :: /vhlth :: /tune :: /mute ::");
		}
		if(level[playerid] >= 2)
		{
			SendMsg(playerid, COLOR_YELLOW, "%s :: /ban :: /explode :: /gethere :: /goto :: /tele :: /jail :: ", msg_lvl2cmds);
			SendClientMessage(playerid, COLOR_YELLOW, ":: /time :: /clearchat :: /weather :: /(give)(set)money :: /(give)(set)score ::");
		}
		if(level[playerid] >= 3)
		{
			SendMsg(playerid, COLOR_YELLOW, "%s :: /timeban :: /weap :: /veh :: /fake ::", msg_lvl3cmds);
			SendClientMessage(playerid, COLOR_YELLOW, ":: /(un)freeze :: /setgreet :: /seepms :: /cage ::");
		}
		if(level[playerid] >= 4)
		{
			SendMsg(playerid, COLOR_YELLOW, "%s :: /setadmin :: /setstat :: /restart(/gmx) :: ", msg_lvl4cmds);
			SendClientMessage(playerid, COLOR_YELLOW, ":: /(re)(un)loadfs :: /gravity :: /crash :: /reloadusers ::");
		}
		SendClientMessage(playerid, COLOR_BLUE, msg_moreinfo);
		return 1;
	}
	return 0;
}

dcmd_givescore(playerid, params[])
{
	if(level[playerid] < 2) return 0;
	new ID2[MAX_PLAYER_NAME], ID, score;
	if(sscanf(params, "si", ID2, score)) {SendMsg(playerid, COLOR_RED, "%s: /givescore [%s] [%s]", usage, partofname, amount); return 1;}
	ID = IDFromName(ID2);
	SetPlayerScore(ID, GetPlayerScore(ID)+score);
	SendMsg(ID, COLOR_YELLOW, msg_addedscore, score);
	SendAMsg(1, aaddedscore, RPN(playerid), playerid, score, RPN(ID), ID);
	return 1;
}

dcmd_setscore(playerid, params[])
{
	if(level[playerid] < 2) return 0;
	new ID2[MAX_PLAYER_NAME], ID, score;
	if(sscanf(params, "si", ID2, score)) {SendMsg(playerid, COLOR_RED, "%s: /setscore [%s] [%s]", usage, partofname, amount); return 1;}
	ID = IDFromName(ID2);
	SetPlayerScore(ID, score);
	SendMsg(ID, COLOR_YELLOW, msg_scoreset, score);
	SendAMsg(1, ascoreset, RPN(playerid), playerid, RPN(ID), ID, score);
	return 1;
}

dcmd_setmoney(playerid, params[])
{
	if(level[playerid] < 2) return 0;
	new ID2[MAX_PLAYER_NAME], ID, money;
	if(sscanf(params, "si", ID2, money)) {SendMsg(playerid, COLOR_RED, "%s: /setmoney [%s] [%s]", usage, partofname, amount); return 1;}
	ID = IDFromName(ID2);
	SetPlayerMoney(ID, money);
	SendMsg(ID, COLOR_YELLOW, msg_moneyset, money);
	SendAMsg(1, amoneyset, RPN(playerid), playerid, RPN(ID), ID, money);
	return 1;
}

dcmd_givemoney(playerid, params[])
{
	if(level[playerid] < 2) return 0;
	new ID2[MAX_PLAYER_NAME], ID, money;
	if(sscanf(params, "si", ID2, money)) {SendMsg(playerid, COLOR_RED, "%s: /givemoney [%s] [%s]", usage, partofname, amount); return 1;}
	ID = IDFromName(ID2);
	GivePlayerMoney(ID, money);
	SendMsg(ID, COLOR_YELLOW, msg_addmoney, money);
	SendAMsg(1, aaddmoney, RPN(playerid), playerid, RPN(ID), ID, money);
	return 1;
}

dcmd_weather(playerid, params[])
{
	if(level[playerid] < 2) return 0;
	new ID;
	if(sscanf(params, "i", ID)) {SendMsg(playerid, COLOR_RED, "%s: /weather [%s]", usage, weatherid); return 1;}
	SetWeather(ID);
	SendAllMsg(COLOR_LGREEN, msg_weather, ID);
	SendAMsg(1, aweather, RPN(playerid), playerid, ID);
	return 1;
}
dcmd_cage(playerid, params[])
{
	if(level[playerid] < 3) return 0;
	new ID, ID2[MAX_PLAYER_NAME], reason[128];
	reason = noreason;
	if(sscanf(params, "sz", ID2, reason)) {SendMsg(playerid, COLOR_RED, "%s: /cage [%s] (%s)", usage, partofname, cmdreason); return 1;}
	ID = IDFromName(ID2);
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
	if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
	if(cages[ID][caged] == 0)
	{
		new Float:x, Float:y, Float:z;
		if(IsPlayerInAnyVehicle(playerid))
		{
			new vehid = GetPlayerVehicleID(playerid);
			RemovePlayerFromVehicle(playerid);
			DestroyVehicle(vehid);
		}
		GetPlayerPos(ID, x, y, z);
		SetPlayerPos(ID, x, y, z+0.7);
		cagep[playerid][cx] = x;
		cagep[playerid][cy] = y;
		cagep[playerid][cz] = z+0.75;
		cages[ID][cage1] = CreateObject(971, x, y, z+0.3, 269.7591, 0.0000, 0.0000);
		cages[ID][cage2] = CreateObject(971, x+3.5, y, z+1, 0.0000, 0.0000, 270.0000);
		cages[ID][cage3] = CreateObject(971, x, y+3, z+1, 0.0000, 0.0000, 0.0000);
		cages[ID][cage4] = CreateObject(971, x, y-3, z+1, 0.0000, 0.0000, 0.0000);
		cages[ID][cage5] = CreateObject(971, x-3.5, y, z+1, 0.0000, 0.0000, 270.0000);
		cages[ID][cage6] = CreateObject(971, x, y, z+4.4, 90.2409, 0.0000, 270.9368);
		cages[ID][caged] = 1;
		SendMsg(playerid, COLOR_LGREEN, msg_caged1, RPN(ID), ID);
		SendMsg(ID, COLOR_YELLOW, msg_caged2, 0);
		SendAllMsg(COLOR_GREEN, msg_caged3, RPN(ID), ID, reason);
		SendAMsg(1, acaged, RPN(ID), ID, RPN(playerid), playerid, reason);
	}
	else
	{
		DestroyObject(cages[ID][cage1]);
		DestroyObject(cages[ID][cage2]);
		DestroyObject(cages[ID][cage3]);
		DestroyObject(cages[ID][cage4]);
		DestroyObject(cages[ID][cage5]);
		DestroyObject(cages[ID][cage6]);
		cages[ID][caged] = 0;
		new string[128];
		format(string, sizeof(string), msg_uncaged1, RPN(ID), ID);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		SendMsg(ID, COLOR_YELLOW, msg_uncaged1, 0);
		SendAllMsg(COLOR_GREEN, msg_uncaged2, RPN(ID), ID);
		SendAMsg(1, auncaged, RPN(ID), ID, RPN(playerid), playerid, reason);
	}
	return 1;
}
dcmd_seepms(playerid, params[])
{
	#pragma unused params
	if(level[playerid] < 3) return 0;
	SendMsg(playerid, COLOR_LGREEN, msg_seepms, seepms[playerid] ? (cfg_off) : (cfg_on));
	if(seepms[playerid]) seepms[playerid] = 0;
	else seepms[playerid] = 1;
	return 1;
}
	
	
	
dcmd_nopm(playerid, params[])
{
	#pragma unused params
	if(nopm[playerid])
	{
		nopm[playerid] = 0;
		SendClientMessage(playerid, COLOR_LGREEN, msg_nopmoff);
	}
	else
	{
		nopm[playerid] = 1;
		SendClientMessage(playerid, COLOR_LGREEN, msg_nopmon);
	}
	return 1;
}
		
dcmd_a(playerid, params[])
{
	if(level[playerid] < 1) return 0;
	new value[128];
	if(sscanf(params, "s", value)) {SendMsg(playerid, COLOR_RED, "%s: /a [%s]", usage, cmdmessage); return 1;}
	new string[128];
	format(string, 128, adminchat, RPN(playerid), playerid, value);
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && level[i] > 0)
		{
			SendClientMessage(i, COLOR_GREEN, string);
		}
	}
	if(logging)
	{
		new File:log = fopen("\\bAdmin\\log.txt", io_append);
		new year, month, day, hour, minute, second;
		gettime(hour, minute, second);
		getdate(year, month, day);
		new sendmsg[256];
		format(sendmsg, 256, "%i/%i/%i %i:%i:%i	-	%s\r\n", day, month, year, hour, minute, second, string);
		fwrite(log, sendmsg);
		fclose(log);
	}
	return 1;
}
dcmd_clearchat(playerid, params[])
{
	#pragma unused params
	if(level[playerid] < 2) return 0;
	for(new i = 0; i < 50; i++) SendClientMessageToAll(COLOR_RED, " ");
	SendAMsg(1, acleared, RPN(playerid), playerid);
	return 1;
}
dcmd_setgreet(playerid, params[])
{
	if(level[playerid] < 3) return 0;
	new value[128];
	if(sscanf(params, "s", value)) {SendMsg(playerid, COLOR_RED, "%s: /setgreet [%s]", usage, cmdmessage); return 1;}
	format(file, 128, USER_FILE, RPN(playerid));
	dini_Set(file, "greet", value);
	SendMsg(playerid, COLOR_LGREEN, "Your greet was set to '%s'", value);
	SendMsg(playerid, COLOR_LGREEN, "This message will be displayed next time you enter the server!", 0);
	return 1;
}

dcmd_freeze(playerid, params[])
{
	if(level[playerid] < 3) return 0;
	new ID, ID2[26], reason[128];
	reason = noreason;
	if(sscanf(params, "sz", ID2, reason)) {SendMsg(playerid, COLOR_RED, "%s: /freeze [%s] (%s)", usage, partofname, cmdreason); return 1;}
	ID = IDFromName(ID2);
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
	if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
	if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_freeze1);
	TogglePlayerControllable(ID, 0);
	SendAllMsg(COLOR_LGREEN, msg_freeze2, RPN(ID), ID, reason);
	SendAMsg(1, afreeze, RPN(playerid), playerid, RPN(ID), ID, reason);
	return 1;
}
dcmd_unfreeze(playerid, params[])
{
	if(level[playerid] < 3) return 0;
	new ID, ID2[26];
	if(sscanf(params, "s", ID2)) {SendMsg(playerid, COLOR_RED, "%s: /unfreeze [%s]", usage, partofname); return 1;}
	ID = IDFromName(ID2);
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
	TogglePlayerControllable(ID, 1);
	SendAllMsg(COLOR_LGREEN, msg_unfreeze, RPN(ID), ID);
	SendAMsg(1, aunfreeze, RPN(playerid), playerid, RPN(ID), ID);
	return 1;
}
	

dcmd_time(playerid, params[])
{
	if(level[playerid] < 2) return 0;
	new time;
	if(sscanf(params, "i", time)) 
	{
		SendMsg(playerid, COLOR_RED, "%s: /time [0-24]", usage); 
		return 1;
	}
	if(time < 0 || time > 24) return SendClientMessage(playerid, COLOR_RED, msg_time);
	SetWorldTime(time);
	SendAMsg(1, atime, RPN(playerid), playerid, time);
	return 1;
}

dcmd_crash(playerid, params[])
{
	if(level[playerid] < 4) return 0;
	new ID, ID2[26];
	if(sscanf(params, "s", ID2)) {SendMsg(playerid, COLOR_RED, "%s: /crash [%s]", usage, partofname); return 1;}
	ID = IDFromName(ID2);
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
	if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
	if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_crash);
	new Float:x, Float:y, Float:z;
	GetPlayerPos(ID, x, y, z);
	new obje = CreatePlayerObject(ID, 1333337, x, y, z, 0, 0, 0);
	DestroyPlayerObject(ID, obje);
	SendAMsg(1, acrash, RPN(playerid), playerid, RPN(ID), ID);
	return 1;
}
dcmd_fake(playerid, params[])
{
	if(level[playerid] < 3) return 0;
	new ID, text[128], ID2[26];
	if(sscanf(params, "ss", ID2, text)) {SendMsg(playerid, COLOR_RED, "%s: /fake [%s] [%s]", partofname, cmdtxt); return 1;}
	ID = IDFromName(ID2);
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
	SendPlayerMessageToAll(ID, text);
	return 1;
}

dcmd_tune(playerid, params[])
{
	#pragma unused params
	if(level[playerid] < 1) return 0;
	if(IsPlayerInAnyVehicle(playerid))
	{
		new Car = GetPlayerVehicleID(playerid), Model = GetVehicleModel(Car);
		switch(Model) 
		{ 
			case 448,461,462,463,468,471,509,510,521,522,523,581,586: 
				return SendClientMessage(playerid,COLOR_RED,msg_tune1);
		}
		ShowMenuForPlayer(Tunning,playerid);
		TogglePlayerControllable(playerid,0);
	}
	else
	{
		return SendClientMessage(playerid,COLOR_RED,msg_tune2);
	}
	return 1;
}

dcmd_reloadusers(playerid, params[])
{
	#pragma unused params
	if(level[playerid] < 4) return 0;
	SendClientMessage(playerid, COLOR_LGREEN, msg_reloadingusers);
	SendAMsg(1, areloaded, RPN(playerid), playerid);
	for(new i = 0; i < MAX_PLAYERS; i++) 
	{
		format(file, 128, USER_FILE, RPN(i));
		if(IsPlayerConnected(i) && dini_Exists(file))
		{
			level[playerid] = dini_Int(file, "level");
			SetPlayerScore(i, dini_Int(file, "score"));
			SetPlayerMoney(i, dini_Int(file, "money"));
		}
	}
	SendClientMessage(playerid, COLOR_BLUE, msg_reloaded);
	return 1;
}

dcmd_gravity(playerid, params[])
{
	if(level[playerid] >= 4)
	{
		if(!strlen(params)) {SendMsg(playerid, COLOR_RED, "%s: /gravity [%s]", usage, cmdvalue); return 1;}
		new string[128];
		format(string, 128, "gravity %s", params);
		SendRconCommand(string);
		format(string, 128, msg_gravity, params);
		SendClientMessageToAll(COLOR_LGREEN, string);
		format(string, 128, agravity, RPN(playerid), playerid, params);
		AdminMsg(1, string);
		return 1;
	}
	return 0;
}

dcmd_reloadfs(playerid, params[])
{
	if(level[playerid] >= 4)
	{
		if(!strlen(params)) {SendMsg(playerid, COLOR_RED, "%s: /reloadfs [%s]", usage, fsname); return 1;}
		new string[128];
		format(string, 128, msg_reloadfs, 0);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		printf(pr_reloaded, RPN(playerid), playerid, params);
		format(string, 128, "reloadfs %s", params);
		SendRconCommand(string);
		return 1;
	}
	return 0;
}

dcmd_unloadfs(playerid, params[])
{
	if(level[playerid] >= 4)
	{
		if(!strlen(params)) {SendMsg(playerid, COLOR_RED, "%s: /unloadfs [%s]", usage, fsname); return 1;}
		new string[128];
		format(string, 128, msg_unloadfs, 0);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		printf(pr_unloadfs, RPN(playerid), playerid, params);
		format(string, 128, "unloadfs %s", params);
		SendRconCommand(string);
		return 1;
	}
	return 0;
}

dcmd_loadfs(playerid, params[])
{
	if(level[playerid] >= 4)
	{
		if(!strlen(params)) {SendMsg(playerid, COLOR_RED, "%s: /loadfs [%s]", usage, fsname); return 1;}
		new string[128];
		format(string, 128, msg_loadfs, 0);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		printf(pr_loadfs, RPN(playerid), playerid, params);
		format(string, 128, "loadfs %s", params);
		SendRconCommand(string);
		return 1;
	}
	return 0;
}

dcmd_gmx(playerid, params[]) return dcmd_restart(playerid, params);

dcmd_restart(playerid, params[])
{
	#pragma unused params
	if(level[playerid] >= 4)
	{
		SendClientMessageToAll(COLOR_BLUE, msg_gmx); 
		printf("%s (%i) restarted the server", RPN(playerid), playerid);
		SetTimerEx("SendRconCommand", 2000, 0, "s", "gmx");
		return 1;
	}
	return 0;
}

dcmd_jail(playerid, params[])
{
	if(level[playerid] >= 2)
	{
		new string[128], ID2[25], ID, reason[128], Float:px, Float:py, Float:pz;
		reason = noreason;
		if(sscanf(params, "sz", ID2, reason)) {SendMsg(playerid, COLOR_RED, "%s: /jail [%s] (%s)", usage, partofname, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
		if(jailed[ID] == 0)
		{
			new r = random(sizeof(jailpos));
			if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_jail1);
			GetPlayerPos(ID, px, py, pz);
			oldpos[ID][interior] = GetPlayerInterior(ID);
			oldpos[ID][ex] = px;
			oldpos[ID][ey] = py;
			oldpos[ID][ez] = pz;
			SetPlayerPos(ID, jailpos[r][ex], jailpos[r][ey], jailpos[r][ez]);
			SetPlayerInterior(ID, jailpos[r][interior]);
			format(string, 128, msg_jail2, RPN(ID), ID, reason);
			SendClientMessageToAll(COLOR_LGREEN, string);
			format(string, 128, ajail, RPN(ID), ID, RPN(playerid), playerid, reason);
			AdminMsg(1, string);
			jailed[ID] = 1;
			return 1;
		}
		else
		{
			SetPlayerPos(ID, oldpos[ID][ex], oldpos[ID][ey], oldpos[ID][ez]);
			SetPlayerInterior(ID, oldpos[ID][interior]);
			format(string, 128, msg_unjail, RPN(ID), ID);
			SendClientMessageToAll(COLOR_LGREEN, string);
			format(string, 128, aunjail, RPN(ID), ID, RPN(playerid), playerid);
			AdminMsg(1, string);
			jailed[ID] = 0;
			return 1;
		}
	}
	return 0;
}
	

dcmd_report(playerid, params[])
{
	new string[128], ID2[MAX_PLAYER_NAME], ID, reason[128];
	if(sscanf(params, "ss", ID2, reason)) {SendMsg(playerid, COLOR_RED, "%s: /report [%s] [%s]", usage, partofname, cmdreason); return 1;}
	ID = IDFromName(ID2);
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
	if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_report1);
	format(string, 128, areport, RPN(ID), ID, RPN(playerid), playerid, reason);
	for(new i = 0; i < MAX_PLAYERS; i++) if(level[i] > 0) SendClientMessage(i, COLOR_RED, string);
	SendClientMessage(playerid, COLOR_BLUE, msg_report2);
	return 1;
}

dcmd_vhlth(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new string[128];
		new Float:value;
		if(sscanf(params, "f", value)) {SendMsg(playerid, COLOR_RED, "%s: /vhlth [%s]", usage, cmdhealth); return 1;}
		if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, msg_vhlth1);
		SetVehicleHealth(GetPlayerVehicleID(playerid), value);
		format(string, 128, msg_vhlth2, floatround(value));
		SendClientMessage(playerid, COLOR_LGREEN, string);
		format(string, 128, avhlth, RPN(playerid), playerid, floatround(value));
		AdminMsg(1, string);
		return 1;
	}
	return 0;
}

dcmd_health(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new string[128];
		new ID2[128];
		new ID;
		new value;
		if(sscanf(params, "si", ID2, value)) {SendMsg(playerid, COLOR_RED, "%s: /health [%s] [%s]", usage, partofname, cmdhealth); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		SetPlayerHealth(ID, value);
		format(string, 128, msg_hlth, value);
		SendClientMessage(ID, COLOR_LGREEN, string);
		format(string, 128, ahlth, RPN(playerid), playerid, RPN(ID), ID, value);
		AdminMsg(1, string);
		return 1;
	}
	return 0;
}

dcmd_veh(playerid, params[])
{
	if(level[playerid] >= 3)
	{
		new string[128], value[128], ID;
		if(sscanf(params, "s", value)) {SendMsg(playerid, COLOR_RED, "%s: /veh [%s]", usage, modelid); return 1;}
		ID = GetVehicleModelIDFromName(value);
		if(ID == -1)
		{
			ID = strval(value);
			if(ID < MIN_VEHI_ID || ID > MAX_VEHI_ID) return SendClientMessage(playerid, COLOR_RED, msg_veh1);
		}
		new Float:x, Float:y, Float:z, Float:a;
		GetPlayerPos(playerid, x, y, z);
		GetXYInFrontOfPlayer(playerid, x, y, 5);
		GetPlayerFacingAngle(playerid, a);
		CreateVehicle(ID, x, y, z + 2.0, a + 90.0, -1, -1, 5000);
		format(string, 128, msg_veh2, aVehicleNames[ID - MIN_VEHI_ID], ID);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		return 1;
	}
	return 0;
}

dcmd_mute(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new string[128];
		new ID2[128];
		new ID;
		new reason[128];
		reason = noreason;
		if(sscanf(params, "sz", ID2, reason)) {SendMsg(playerid, COLOR_RED, "%s: /mute [%s] (%s)", usage, partofname, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!mute[ID])
		{
			if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
			if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_mute1);
			if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
			format(string, 128, msg_mute2, RPN(ID), ID, reason);
			SendClientMessageToAll(COLOR_LGREEN, string);
			format(string, 128, amute, RPN(playerid), playerid, RPN(ID), ID, reason);
			AdminMsg(1, string);
			mute[ID] = 1;
			return 1;
		}
		else
		{
			if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
			format(string, 128, msg_unmute, RPN(ID), ID);
			SendClientMessage(ID, COLOR_LGREEN, string);
			format(string, 128, aunmute, RPN(playerid), playerid, RPN(ID), ID);
			AdminMsg(1, string);
			mute[ID] = 0;
			return 1;
		}
	}
	return 0;
}

dcmd_tele(playerid, params[])
{
	if(level[playerid] >= 2)
	{
		new string[128];
		new ID2[128];
		new ID4[128];
		new ID3;
		new ID;
		if(sscanf(params, "ss", ID4, ID2)) {SendMsg(playerid, COLOR_RED, "%s: /tele [%s] [%s]", usage, teleportee, destination); return 1;}
		ID = IDFromName(ID2);
		ID3 = IDFromName(ID4);
		if(!IsPlayerConnected(ID) || !IsPlayerConnected(ID3)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		new Float:x, Float:y, Float:z, Float:frontx, Float:fronty;
		GetXYInFrontOfPlayer(ID3, frontx, fronty, 4);
		GetPlayerPos(ID, x, y, z);
		if(IsPlayerInAnyVehicle(ID3))
		{
			SetVehiclePos(GetPlayerVehicleID(ID3), frontx, fronty, z);
			LinkVehicleToInterior(GetPlayerVehicleID(ID3), GetPlayerInterior(ID3));
		}
		else
		{
			SetPlayerPos(ID3, frontx, fronty, z);
			SetPlayerInterior(ID3, GetPlayerInterior(ID3));
		}
		format(string, 128, msg_teleported, RPN(ID), ID);
		SendClientMessage(ID, COLOR_LGREEN, string);
		format(string, 128, atele, RPN(playerid), playerid, RPN(ID3), ID3, RPN(ID), ID);
		AdminMsg(1, string);
		return 1;
	}
	return 0;
}
dcmd_goto(playerid, params[])
{
	if(level[playerid] >= 2)
	{
		new string[128];
		new ID2[128];
		new ID;
		if(sscanf(params, "s", ID2)) {SendMsg(playerid, COLOR_RED, "%s: /goto [%s]", usage, partofname); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_goto);
		new Float:x, Float:y, Float:z, Float:frontx, Float:fronty;
		GetXYInFrontOfPlayer(ID, frontx, fronty, 4);
		GetPlayerPos(ID, x, y, z);
		if(IsPlayerInAnyVehicle(playerid))
		{
			SetVehiclePos(GetPlayerVehicleID(playerid), frontx, fronty, z);
			LinkVehicleToInterior(GetPlayerVehicleID(playerid), GetPlayerInterior(ID));
		}
		else
		{
			SetPlayerPos(playerid, frontx, fronty, z);
			SetPlayerInterior(playerid, GetPlayerInterior(ID));
		}
		format(string, 128, msg_teleported, RPN(ID), ID);
		SendClientMessage(playerid, COLOR_LGREEN, string);
		format(string, 128, agoto, RPN(playerid), playerid, RPN(ID), ID);
		AdminMsg(1, string);
		return 1;
	}
	return 0;
}

dcmd_gethere(playerid, params[])
{
	if(level[playerid] >= 2)
	{
		new string[128];
		new ID2[128];
		new ID;
		if(sscanf(params, "s", ID2)) {SendMsg(playerid, COLOR_RED, "%s: /gethere [%s]", usage, partofname); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_gethere);
		new Float:x, Float:y, Float:z, Float:frontx, Float:fronty;
		GetXYInFrontOfPlayer(playerid, frontx, fronty, 4);
		GetPlayerPos(playerid, x, y, z);
		if(IsPlayerInAnyVehicle(ID))
		{
			SetVehiclePos(GetPlayerVehicleID(ID), frontx, fronty, z);
			LinkVehicleToInterior(GetPlayerVehicleID(ID), GetPlayerInterior(playerid));
		}
		else
		{
			SetPlayerPos(ID, frontx, fronty, z);
			SetPlayerInterior(ID, GetPlayerInterior(playerid));
		}
		format(string, 128, msg_teleported, RPN(playerid), playerid);
		SendClientMessage(ID, COLOR_LGREEN, string);
		format(string, 128, agethere, RPN(playerid), playerid, RPN(ID), ID);
		AdminMsg(1, string);
		return 1;
	}
	return 0;
}
dcmd_ann(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new string[128];
		new value[128];
		if(sscanf(params, "s", value)) {SendMsg(playerid, COLOR_RED, "%s: /ann [%s]", usage, cmdmessage); return 1;}
		format(string, 128, "~w~%s", value);
		TextDrawSetString(annTD, string);
		TextDrawShowForAll(annTD);
		SetTimer("Tdtimer", 5000, 0);
		anns++;
		printf(msg_announce, RPN(playerid), value);
		return 1;
	}
	return 0;
}

dcmd_announce(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new string[128];
		new value[128];
		if(sscanf(params, "s", value)) {SendMsg(playerid, COLOR_RED, "%s: /announce [%s]", usage, cmdmessage); return 1;}
		format(string, 128, "~w~%s", value);
		TextDrawSetString(annTD, string);
		TextDrawShowForAll(annTD);
		SetTimer("Tdtimer", 5000, 0);
		anns++;
		printf(msg_announce, RPN(playerid), value);
		return 1;
	}
	return 0;
}

forward Tdtimer();

public Tdtimer()
{
	anns--;
	if(!anns) TextDrawHideForAll(annTD);
}

dcmd_weap(playerid, params[])
{
	if(level[playerid] >= 3)
	{
		new string[128];
		new ID2[25];
		new ID;
		new value[128];
		new ammo
		if(sscanf(params, "ssi", ID2, value, ammo)) {SendMsg(playerid, COLOR_RED, "%s: /weap [%s] [%s] [%s]", usage, partofname, weapname, cmdammo); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		new weaponid = GetWeaponModelIDFromName(value);
		if (weaponid == -1) 
		{
			weaponid = strval(value);
			if (weaponid < 0 || weaponid > 47) 
			{
				SendClientMessage(playerid, COLOR_RED, msg_weap1);
				return 1;
			}
		}
		format(string, 128, msg_weap2, WeaponNames[weaponid], ammo);
		SendClientMessage(ID, COLOR_LGREEN, string);
		format(string, 128, aweap, RPN(playerid), playerid, RPN(ID), ID, WeaponNames[weaponid], ammo);
		AdminMsg(3, string);
		GivePlayerWeapon(ID, weaponid, ammo);
		return 1;
	}
	return 0;
}	

dcmd_akill(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new string[128];
		new ID2[25];
		new ID;
		new value[128];
		value = noreason;
		if(sscanf(params, "sz", ID2, value)) {SendMsg(playerid, COLOR_RED, "%s: /akill [%s] (%s)", usage, partofname, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_akill1);
		if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
		format(string, 128, msg_akill2, RPN(ID), ID, value);
		SendClientMessageToAll(COLOR_LGREEN, string);
		format(string, 128, aakill, RPN(playerid), playerid, RPN(ID), ID, value);
		AdminMsg(1, string);
		SetPlayerHealth(ID, 0);
		PlayerPlaySound(ID, 1190, 0.0, 0.0, 0.0);
		return 1;
	}
	return 0;
}	

dcmd_explode(playerid, params[])
{
	if(level[playerid] >= 2)
	{
		new string[128];
		new ID;
		new ID2[25];
		new value[128];
		value = noreason;
		if(sscanf(params, "sz", ID2, value)) {SendMsg(playerid, COLOR_RED, "%s: /explode [%s] (%s)", usage, partofname, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_explode1);
		if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
		format(string, 128, msg_explode2, RPN(ID), ID, value);
		SendClientMessageToAll(COLOR_LGREEN, string);
		format(string, 128, aexplode, RPN(playerid), playerid, RPN(ID), ID, value);
		AdminMsg(2, string);
		new Float:x, Float:y, Float:z;
		SetPlayerHealth(ID, 10);
		GetPlayerPos(ID, x, y, z);
		CreateExplosion(x, y, z, 7, 10);
		return 1;
	}
	return 0;
}	

dcmd_kick(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new value[128];
		new string[128];
		new ID;
		new ID2[25];
		value = noreason;
		if(sscanf(params, "sz", ID2, value)) {SendMsg(playerid, COLOR_RED, "%s: /kick [%s] (%s)", usage, partofname, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_kick1);
		if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
		format(string, 128, msg_kick2, RPN(ID), ID, value);
		SendClientMessageToAll(COLOR_LGREEN, string);
		format(string, 128, akick, RPN(playerid), playerid, RPN(ID), ID, value);
		AdminMsg(1, string);
		TogglePlayerControllable(ID, 0);
		SendClientMessage(ID, COLOR_RED, kickmsg);
		Kick(ID);
		return 1;
	}
	return 0;
}

dcmd_slap(playerid, params[])
{
	if(level[playerid] >= 1)
	{
		new string[128];
		new ID;
		new ID2[25];
		new value[128];
		value = noreason;
		if(sscanf(params, "sz", ID2, value)) {SendMsg(playerid, COLOR_RED, "%s: /slap [%s] (%s)", usage, partofname, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_slap1);
		if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
		new Float:x, Float:y, Float:z;
		GetPlayerPos(ID, x, y, z);
		SetPlayerPos(ID, x, y, z+6);
		format(string, 128, msg_slap2, RPN(ID), ID, value);
		SendClientMessageToAll(COLOR_LGREEN, string);
		format(string, 128, aslap, RPN(playerid), playerid, RPN(ID), ID, value);
		AdminMsg(1, string);
		return 1;
	}
	return 0;
}

dcmd_ban(playerid, params[])
{
	if(level[playerid] >= 2)
	{
		new value[128];
		new string[128];
		new ID;
		new ID2[25];
		value = noreason;
		if(sscanf(params, "sz", ID2, value)) {SendMsg(playerid, COLOR_RED, "%s: /ban [%s] (%s)", usage, partofname, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_ban1);
		if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
		format(string, 128, msg_ban2, RPN(ID), ID, value);
		SendClientMessageToAll(COLOR_LGREEN, string);
		format(string, 128, aban, RPN(playerid), playerid, RPN(ID), ID, value);
		AdminMsg(2, string);
		TogglePlayerControllable(ID, 0);
		SendClientMessage(ID, COLOR_RED, kickmsg);
		format(string, 128, banreason, value, RPN(playerid));
		format(file, 128, USER_FILE, RPN(playerid));
		dini_IntSet(file, "banned", 1);
		BanEx(ID, string);
		return 1;
	}
	return 0;
}

dcmd_timeban(playerid, params[])
{
	if(level[playerid] >= 3)
	{
		new value[128];
		new string[128];
		new time;
		new ID;
		new ID2[25];
		value = noreason;
		if(sscanf(params, "sdz", ID2, time, value)) {SendMsg(playerid, COLOR_RED, "%s: /timeban [%s] [%s] (%s)", usage, partofname, cmdminutes, cmdreason); return 1;}
		ID = IDFromName(ID2);
		if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		if(ID == playerid) return SendClientMessage(playerid, COLOR_RED, msg_timeban1);
		if(level[playerid] < level[ID]) return SendClientMessage(playerid, COLOR_RED, higherlvl);
		format(string, 128, msg_timeban2, RPN(ID), ID, time, value);
		SendClientMessageToAll(COLOR_LGREEN, string);
		format(string, 128, atimeban, RPN(playerid), playerid, RPN(ID), ID, time, value);
		dini_IntSet(file, "banned", 1);
		AdminMsg(3, string);
		TimeBan(ID, time);
		return 1;
	}
	return 0;
}
dcmd_setadmin(playerid, params[])
{
	if(level[playerid] >= 4 || IsPlayerAdmin(playerid))
	{
		if(!strlen(params)) {SendMsg(playerid, COLOR_RED, "%s: /setadmin [%s] [%s]", usage, partofname, cmdlevel); return 1;}
		new value, playerid2, ID[25];
		sscanf(params, "si", ID, value);
		playerid2 = IDFromName(ID);
		if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid, COLOR_RED, notconnected);
		format(file, sizeof(file), USER_FILE, RPN(playerid2));
		if(value > 4 || value < 0) return SendClientMessage(playerid, COLOR_RED, msg_setadmin1);
		dini_IntSet(file, "level", value);
		level[playerid2] = value;
		format(file, 128, msg_setadmin2, RPN(playerid2), playerid2, value);
		SendClientMessage(playerid, COLOR_YELLOW, file);
		format(file, 128, msg_setadmin3, value);
		SendClientMessage(playerid2, COLOR_YELLOW, file);
		format(file, 128, asetadmin, RPN(playerid), playerid, RPN(playerid2), playerid2, value);
		print(file);
		AdminMsg(1, file);
		return 1;
	}
	return 0;
}

dcmd_info(playerid, params[])
{
	new string[128];
	new ID2[25], ID, IP[16];
	if(sscanf(params, "s", ID2))
	{
		GetPlayerIp(playerid, IP, 16);
		format(string, 128, yourinfo, 0);
		SendClientMessage(playerid, COLOR_BLUE, string);
		format(string, 128, iscore, GetPlayerScore(playerid));
		SendClientMessage(playerid, COLOR_YELLOW, string);	
		format(string, 128, imoney, GetPlayerMoney(playerid));
		SendClientMessage(playerid, COLOR_YELLOW, string);
		format(string, 128, ilevel, level[playerid], lstring[level[playerid]]);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		format(string, 128, iip, IP);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		printf(msg_info, RPN(playerid), playerid);
		return 1;
	}
	ID = IDFromName(ID2);
	if(ID == playerid)
	{
		GetPlayerIp(playerid, IP, 16);
		format(string, 128, yourinfo, 0);
		SendClientMessage(playerid, COLOR_BLUE, string);
		format(string, 128, iscore, GetPlayerScore(playerid));
		SendClientMessage(playerid, COLOR_YELLOW, string);	
		format(string, 128, imoney, GetPlayerMoney(playerid));
		SendClientMessage(playerid, COLOR_YELLOW, string);
		format(string, 128, ilevel, level[playerid], lstring[level[playerid]]);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		format(string, 128, iip, IP);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		printf(ainfo, RPN(playerid), playerid);
		return 1;
	}
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, notconnected);
	format(file, 128, USER_FILE, RPN(ID));
	GetPlayerIp(ID, IP, 16);
	format(string, 128, msg_info, RPN(ID), ID);
	SendClientMessage(playerid, COLOR_BLUE, string);
	format(string, 128, iscore, GetPlayerScore(ID));
	SendClientMessage(playerid, COLOR_YELLOW, string);	
	format(string, 128, imoney, GetPlayerMoney(ID));
	SendClientMessage(playerid, COLOR_YELLOW, string);
	format(string, 128, ilevel, level[ID], lstring[level[ID]]);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	format(string, 128, iip, IP);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	printf(ainfo2, RPN(playerid), playerid, RPN(ID), ID);
	if(level[playerid] == 4 && dini_Exists(file))
	{
		format(file, 128, USER_FILE, RPN(ID));
		format(string, 128, ipassword, dini_Get(file, "password"));
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
	format(string, 128, ainfo, RPN(playerid), playerid, RPN(ID), ID);
	print(string);
	return 1;
}
		
dcmd_register(playerid, params[])
{
	new string[128];
	format(string, sizeof(string), USER_FILE, RPN(playerid));
	if(!strlen(params))
	{
		SendMsg(playerid, COLOR_RED, "%s: /register [%s]", usage, cmdpassword);
		return 1;
	}
	else if(!dini_Exists(string))
	{
		dini_Create(string);
		dini_IntSet(string, "hashpass", udb_hash(params));
		dini_Set(string, "password", params);
		dini_IntSet(string, "level", 0);
		dini_IntSet(string, "score", 0);
		dini_IntSet(string, "money", 10000);
		new IP[16];
		GetPlayerIp(playerid, IP, 16);
		dini_Set(string, "IP", IP);
		format(string, 128, msg_register1, RPN(playerid), params);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		printf(pr_register, RPN(playerid), playerid, params);
		logged[playerid] = 1;
		SendClientMessage(playerid, COLOR_YELLOW, msg_autologged);
		format(string, 128, areg1, RPN(playerid), playerid);
		AdminMsg(1, string);
		format(string, 128, areg2, params);
		AdminMsg(4, string);
		#if defined _sampmysql_included
		if(mysql)
		{
			format(string, 128, "INSERT into %s (player, score, money, online) VALUES('%s', '%i', '%i', '1')", mysql_table, RPN(playerid), GetPlayerScore(playerid), GetPlayerMoney(playerid));
			samp_mysql_query(string);
		}
		#endif
	}
	else
	{
		SendClientMessage(playerid, COLOR_RED, msg_register2);
	}
	return 1;
}

dcmd_login(playerid, params[])
{
	new string[128];
	format(file, sizeof(string), USER_FILE, RPN(playerid));
	if(!strlen(params))
	{
		SendMsg(playerid, COLOR_RED, "%s: /login [%s]", usage, cmdpassword); 
		return 1;
	}
	new tmp[256], tmp2[256];
	tmp = dini_Get(file, "hashpass");
	tmp2 = dini_Get(file, "password");
	dini_IntSet(file, "hashpass", udb_hash(tmp2));
	format(tmp, 256, "%i", udb_hash(tmp2));
	if(logged[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, msg_login1);
	if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, msg_login2);
	if(udb_hash(params) != strval(tmp)) 
	{
		format(string, 128, msg_login3, RPN(playerid));
		SendClientMessage(playerid, COLOR_RED, string);
	}
	else
	{
		format(string, 128, msg_login4, RPN(playerid), playerid);
		AdminMsg(1, string);
		SetPlayerScore(playerid, dini_Int(file, "score"));
		SetPlayerMoney(playerid, dini_Int(file, "money"));
		level[playerid] = dini_Int(file, "level");
		logged[playerid] = 1;
		new IP[16];
		GetPlayerIp(playerid, IP, 16);
		dini_Set(file, "IP", IP);
		SendClientMessage(playerid, COLOR_YELLOW, msg_login5);
		format(string, 128, lvlmsg, level[playerid], lstring[level[playerid]]);
		SendClientMessage(playerid, COLOR_BLUE, string);
	}
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{

new Menu:Current = GetPlayerMenu(playerid);
if(Current == Tunning)
{
	switch(row)
	{
		case 0:
		{
			ShowMenuForPlayer(Ccolors,playerid);
		}
		case 1:
		{
			ShowMenuForPlayer(Wheels,playerid);
		}
		case 2:
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				
				AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
				TogglePlayerControllable(playerid,1);
			}
		}
		case 3:
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				
				AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
				TogglePlayerControllable(playerid,1);
			}
		}
		case 4:
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				
				AddVehicleComponent(GetPlayerVehicleID(playerid),1086);
				TogglePlayerControllable(playerid,1);
			}
		}
	}
}	else if(Current == Ccolors)	
	{
		switch(row)
		{
			case 0:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehicleColor(GetPlayerVehicleID(playerid),0,0);
				}
			}
			case 1:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehicleColor(GetPlayerVehicleID(playerid),1,1);
				}
			}
	        case 2:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehicleColor(GetPlayerVehicleID(playerid),3,3);
				}
			}
	        case 3:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehicleColor(GetPlayerVehicleID(playerid),16,16);
				}
			}
			case 4:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehicleColor(GetPlayerVehicleID(playerid),79,79);
				}
			}
			case 5:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehicleColor(GetPlayerVehicleID(playerid),126,126);
				}
			}
			case 6:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehicleColor(GetPlayerVehicleID(playerid),6,6);
				}
			}
			case 7:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehiclePaintjob(GetPlayerVehicleID(playerid),0);
				}
			}
			case 8:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehiclePaintjob(GetPlayerVehicleID(playerid),1);
				}
			}
			case 9:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					ChangeVehiclePaintjob(GetPlayerVehicleID(playerid),2);
				}
			}
		}
		OnPlayerExitedMenu(playerid);
	}
	else if(Current == Wheels)
	{
		switch(row)
		{
			case 0:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1079);
				}
			}
			case 1:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1075);
				}
			}
	        case 2:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1074);
				}
			}
	        case 3:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1081);
				}
			}
			case 4:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1080);
				}
			}
			case 5:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1073);
				}
			}
			case 6:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1077);
				}
			}
			case 7:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1083);
				}
			}
			case 8:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
					
					AddVehicleComponent(GetPlayerVehicleID(playerid),1082);
				}
			}
			case 9:
	        {
				if(IsPlayerInAnyVehicle(playerid))
				{
				
					AddVehicleComponent(GetPlayerVehicleID(playerid),1085);
				}
			}
		}
		OnPlayerExitedMenu(playerid);
	}
}
public OnPlayerExitedMenu(playerid)
{
	TogglePlayerControllable(playerid, 1);
	return 1;
}